package com.mes.utils;

import java.util.List;
import java.util.Map;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONObject;

public class JsonUtil {
	@SuppressWarnings("unchecked")
	public static JSONArray listToJsonArray(List<Map> list) {
		JSONArray array = new JSONArray();
		JSONObject obj = null;
		for (Map map : list) {
			obj = new JSONObject();
			for (Object key : map.keySet()) {
				try {
					obj.put((String)key, map.get(key));
				} catch (Exception e) {
				}
			}
			array.put(obj);
		}
		
		return array;
	}
}